# Copyright (C) 2018 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("//tools/build:rules.bzl", "android_dynamic_library", "cc_copts", "cc_dynamic_library")

cc_library(
    name = "cc",
    srcs = glob([
        "*.cpp",
        "*.h",
    ]),
    copts = cc_copts() + select({
        "//tools/build:linux": ["-DVK_USE_PLATFORM_XCB_KHR"],
        "//tools/build:darwin": [],
        "//tools/build:windows": ["-DVK_USE_PLATFORM_WIN32_KHR"],
        # Android
        "//conditions:default": ["-DVK_USE_PLATFORM_ANDROID_KHR"],
    }) + [
        "-fno-rtti",
        "-fno-exceptions",
    ],
    linkopts = select({
        "//tools/build:linux": ["-lpthread"],
        "//tools/build:darwin": [],
        "//tools/build:windows": ["-lpthread"],
        # Android
        "//conditions:default": [
            "-ldl",
            "-lm",
        ],
    }),
    visibility = ["//visibility:public"],
    deps = [
        "//core/vulkan/cc/include/vulkan",
    ],
)

cc_library(
    name = "headers",
    srcs = glob([
        "*.h",
    ]),
    copts = cc_copts() + select({
        "//tools/build:linux": ["-DVK_USE_PLATFORM_XCB_KHR"],
        "//tools/build:darwin": [],
        "//tools/build:windows": ["-DVK_USE_PLATFORM_WIN32_KHR"],
        # Android
        "//conditions:default": ["-DVK_USE_PLATFORM_ANDROID_KHR"],
    }),
    visibility = ["//visibility:public"],
    deps = [
        "//core/vulkan/cc/include/vulkan",
    ],
)

cc_dynamic_library(
    name = "libVkLayer_VirtualSwapchain",
    visibility = ["//visibility:public"],
    exports = "virtual_swapchain_desktop.exports",
    deps = [":cc"],
)

android_dynamic_library(
    name = "libVkLayer_VirtualSwapchain_android",
    visibility = ["//visibility:public"],
    exports = "virtual_swapchain_android.exports",
    deps = [":cc"],
)

filegroup(
    name = "json",
    srcs = ["VirtualSwapchainLayer.json"],
    visibility = ["//visibility:public"],
)
